package com.asdc.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName GateWayConfig
 * @Author bsy
 * @Description : GateWay路由 代码方式:用 http://localhost:9527/sports 访问 http://news.baidu.com/sports
 * @Date 2021/12/12 11:17
 * @Version 1.0
 */

@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator gateWayLocator(RouteLocatorBuilder routeBuilder) {
        return routeBuilder.routes()
                .route("gate_way_code_config", r ->
                        r.path("/sports")
                                .uri("http://news.baidu.com/sports")).build();
    }

}
